package first.niuke.simple;

import java.util.HashMap;

/**
 * @ClassName NC61
 * @description:
 * @author: 荣燊
 * @create: 2021-04-06 21:58
 **/
public class NC61 {
    public static int[] main(String[] args) {
        int[] numbers = {3, 2, 4};
        int target = 6;

        HashMap<Integer, Integer> map = new HashMap<>();
//        for (int i=0; i<numbers.length; i++) {
//            map.put(i+1, numbers[i]);
//        }

        //保存到map
        for (int i=0; i<numbers.length; i++) {
            int tmp = numbers[i];
            if (map.containsKey(target-tmp)) {
                return new int[] {i+1, map.get(target-tmp)};
            }
            map.put(numbers[i], i+1);
        }
        return new int[0];
    }
}
